package com.fromfuture.xuhuidoc.android.activity;


import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;

import com.fromfuture.xuhuidoc.R;
import com.fromfuture.xuhuidoc.android.Interface.Interface;
import com.fromfuture.xuhuidoc.android.activity.mainframe.MainFrameActivity;
import com.fromfuture.xuhuidoc.android.commonresouce.MyUrl;
import com.fromfuture.xuhuidoc.android.utils.MySharedPreferencesUtils;
import com.umeng.analytics.MobclickAgent;

import org.w3c.dom.Text;

import app.auto.runner.ActivityBase;
import app.auto.runner.base.SPrefUtil;

public class WelcomeActivity extends ActivityBase {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SPrefUtil.iniContext(getApplication());
        setContentView(R.layout.activity_welcome);

        MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
        init();

        if (SPrefUtil.getValue("G_WEBBASE").toString().equals("test")) {
            ((TextView) findViewById(R.id.ceshi)).setText("测试版");
        } else {
            ((TextView) findViewById(R.id.ceshi)).setText("正式版");
        }

        getImageView(R.id.img).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplication(), MainFrameActivity.class);
                startActivity(intent);
                finish();
            }
        });
        findViewById(R.id.ceshi).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyUrl.change((Activity) v.getContext());
            }
        });
    }

    //友盟session 统计
    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    //友盟session 统计
    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    public static void onProfileSignIn(String ID) {
        MobclickAgent.onProfileSignIn("userID");
    }

    public static void onProfileSignIn(String Provider, String ID) {
        MobclickAgent.onProfileSignIn("WB", "userID");
    }

    public static void onProfileSignOff() {
    }


    boolean finish;

    private void init() {
        MySharedPreferencesUtils.putValue(this, "ISFIRST", "HASLOGIN", "NO");
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (finish) {
                    return;
                }
                Intent intent = new Intent(getApplication(), MainFrameActivity.class);
                startActivity(intent);
                finish();
            }
        }, 3000);
        findViewById(R.id.img).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish = true;
                Intent intent = new Intent(getApplication(), MainFrameActivity.class);
                startActivity(intent);
            }
        });

    }


}
